const fieldList = [ // 新增弹出数据
  { label: '父级组织', value: 'pid', type: 'select', option: 'sysOrg',  loading: true, remote:true, store:"dictSrv/sysOrg", width: '300px'},
  { label: '组织名称', value: 'name', type: 'input', width: '300px' },
  { label: '组织编码', value: 'code', type: 'input', width: '300px' },
  { label: '创立时间', value: 'stime', type: 'date', width: '300px' },
  { label: '部门负责人', value: 'chargeuid', type: 'select', option: 'sysUser', loading: true, remote:true, store:"dictSrv/sysUser", width: '300px'},
  { label: '分管副总', value: 'prechargeuid', type: 'select', option: 'sysUser', loading: true, remote:true, store:"dictSrv/sysUser", width: '300px'},
  { label: '组织描述', value: 'desc', type:'textarea', width: '600px' }
]

const rules = {
	name: [{ required: true, message: '组织名称', trigger: 'change' }],
	code: [{ required: true, message: '组织编码', trigger: 'change' }],
  stime: [{ required: true, message: '创立时间', trigger: 'change' }],
  chargeuid: [{ required: true, message: '部门负责人', trigger: 'change' }]
}

const fieldData = (data)=>{
  var dataset = {};
  for (var idx = 0; idx < fieldList.length; idx++) {
    var ckey  = fieldList[idx].value;
    dataset[ckey] = (data && data[ckey])? data[ckey]:'';
  }
  dataset.id = (data && data.id)? data.id:0;
  return dataset;
}

export default {
  fieldList,rules,fieldData
}